#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
string s;
string s2;
string ss[1000];
char s4[10240];

void chuli()
{
	getline(cin,s);
	getline(cin,s2);
	
	int pos = s2.find(" ");
	string s2_1 = s2.substr(0,pos);
	string s2_2 = s2.substr(pos+1,s2.size());
	
	int cnt = 0;
	pos = s.find(" ");
	
	while(pos>0)
	{
		ss[cnt] = s.substr(0,pos);
		
		
		s.erase(0,pos+1);	
		pos = s.find(" ");
		cnt++;
	}	
	if (s.size()>0)
		ss[cnt] = s;
	

	
	
	/*
	cout << s << endl;
	cout << s2 << endl;	
	cout << s2_1 << endl;	
	cout << s2_2 << endl;
	cout << "=================" << endl;	
	*/
	int count = 0;
	for (int i=0;i<=cnt;i++)
	{
		//cout << i << "=" << ss[i] << endl;
		string s3;
		
		if (strcasecmp(ss[i].c_str(),s2_1.c_str())==0)		
		{
				s3 = s2_2 ;
				count++;
				//cout << s2_2 << " ";
		}
		else {
			s3 = ss[i] ;
		}	
		
		
		strcat(s4,s3.c_str());
		if (i!=cnt)
			strcat(s4," ");
		
		//cout << ss[i] << ss[i].size()<< endl;
	}
	if (s4[0] >='a' && s4[0]<='z')
		s4[0] = s4[0]-32;
	cout << count << endl;
	cout << s4 ;
	return ;
}
int main()
{
	chuli();
	return 0;
}
